import Vue from 'vue'
import Vuex from 'vuex'
// import { setSession, getSession, clearSession, hasKey} from '../utils/session.js'

//挂载Vuex
Vue.use(Vuex);

const state = {
    isCollapse: true,   //折叠栏的值 
    language: JSON.parse(sessionStorage.getItem("language")) || "cn",//语言切换
    //风格切换
    theme: JSON.parse(sessionStorage.getItem("theme")) || "dark",
    themeBg: require("../assets/login-bc.png"),
    themeHref: "../static/css/global.css",
    Authorization: localStorage.getItem('Authorization'),
    userInfo: localStorage.getItem('userInfo'),
    navData: [],
}

const mutations = {
    userInfo(state,user){
        state.userInfo = user;
        localStorage.setItem('userInfo', user);
    },
    getTokens (state, user) {
        state.Authorization = user.Authorization;
        localStorage.setItem('Authorization', user.Authorization);
    },
    collapseMenu(state) {
        state.isCollapse = !state.isCollapse;    //折叠侧边菜单栏
    },
    setLanguage(state, payload) {
        state.language = payload;//语言切换
        // sessionStorage.setItem('language',JSON.stringify(payload))
    },
    theme(state,theme) {
        state.theme = theme.theme
        state.themeBg = theme.themeBg
        state.themeHref = theme.themeHref
    },
    navData(state,data) {
        state.navData = data; //侧导航栏数据
    },
}

const actions = {
    
}
const getters = {

}

export default new Vuex.Store({
    state,
    mutations,
    actions,
    getters
})
